package cn.tradewin.advisor.pages.project.plan;

import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.slf4j.Logger;

import cn.tradewin.advisor.exceptions.DBException;
import cn.tradewin.advisor.persist.model.Wbs;
import cn.tradewin.advisor.persist.services.WbsService;

public class WbsAdd {

	@Property
	private Wbs wbs;

	@Inject
	private Logger log;

	@Inject
	private WbsService wbsService;
	
	
	void onPrepareForRender() throws DBException {
		
	}

	@Log
	void onPrepare() throws Exception {
		if (wbs == null) {
			wbs = new Wbs();
		}
	}

	@Log
	Object onSubmit() {
		try {
			wbsService.addWbs(wbs);
		} catch (Exception e) {
			log.debug(e.getMessage());
		}
		return WbsManagement.class;
	}

}
